package com.googlecode.nauka.mydbplugin.editor;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;

public class SQLEditorInput implements IEditorInput{
    private String tableName;

    public SQLEditorInput(String table){
        this.tableName = table;
    }

    public boolean exists(){
        return false;
    }

    public String getToolTipText(){
        return tableName;
    }

    public ImageDescriptor getImageDescriptor(){
        return null;
    }

    public String getName(){
        return tableName + ".sql";
    }

    public IPersistableElement getPersistable(){
        return null;
    }

    public boolean equals(Object obj){
        if(super.equals(obj))
            return true;
        if(!(obj instanceof SQLEditorInput))
            return false;
        SQLEditorInput other = (SQLEditorInput)obj;
        return tableName.equals(other.tableName);
    }

    public int hashCode(){
        return tableName.hashCode();
    }

    @SuppressWarnings("unchecked")
    public Object getAdapter(Class adapter){
        return null;
    }

    public String getQuery(){
        return "select t.* from " + tableName + " t";
    }
}
